

local composer = require( "composer" )
local scene = composer.newScene()

local util = require('Utility.util')

---------------------------------------------------------------------------------
local function getTextView()

	local options2 = 
	{
	    text = "1111111",
	    x = display.contentWidth/2,
	    y = display.contentHeight/2,
	    width = display.contentWidth,     --required for multi-line and alignment
	    font = native.systemFont,
	    fontSize = 20
	}
	local myText2 = display.newText( options2 )
	myText2:setFillColor( 1, 1, 1 )



	local function requestSuccess( rs )
	    myText2.text = util.JSON.stringify(rs)
	    --myText2.text = os.date()
	    native.showAlert('aaa','bbbb')
	end

	local headers = {}

	--headers["Content-Type"] = "application/x-www-form-urlencoded"
	--headers["Accept-Language"] = "en-US"

	local params = {}

	util.Network.requestGet({
		url = 'http://f.eboic.com/?c=ssq',
		dataType = 'json',
		success = requestSuccess
	});

	return myText2
end


function scene:create( event )
	local sceneGroup = self.view

	
	local txt = getTextView()
	sceneGroup:insert(txt)

end



function scene:show( event )
	local sceneGroup = self.view
	local phase = event.phase
	
	if phase == "will" then
		-- Called when the scene is still off screen and is about to move on screen
	elseif phase == "did" then
		-- Called when the scene is now on screen
		-- 
		-- INSERT code here to make the scene come alive
		-- e.g. start timers, begin animation, play audio, etc.
	end	
end

function scene:hide( event )
	local sceneGroup = self.view
	local phase = event.phase
	
	if event.phase == "will" then
		-- Called when the scene is on screen and is about to move off screen
		--
		-- INSERT code here to pause the scene
		-- e.g. stop timers, stop animation, unload sounds, etc.)
	elseif phase == "did" then
		-- Called when the scene is now off screen
	end	
end


function scene:destroy( event )
	local sceneGroup = self.view
	
	-- Called prior to the removal of scene's "view" (sceneGroup)
	-- 
	-- INSERT code here to cleanup the scene
	-- e.g. remove display objects, remove touch listeners, save state, etc.
end

---------------------------------------------------------------------------------

-- Listener setup
scene:addEventListener( "create", scene )
scene:addEventListener( "show", scene )
scene:addEventListener( "hide", scene )
scene:addEventListener( "destroy", scene )

---------------------------------------------------------------------------------

return scene